Script to automate creation of DOORS Project Archive

Anyone have a script that could be scheduled to create a DOORS Project Archive automatically?


jhays - Tue Apr 01 10:30:12 EDT 2014

Re: Script to automate creation of DOORS Project Archive
SudarshanRao - Thu Apr 03 01:13:22 EDT 2014

It would be quite simple script, with a loop (for project in database do) and the archive function within it. But, since in DOORS you can have project within a project, simply archiving all projects may mean that you'd end up duplicating data.

So you may want to consider having all items at root level to be of type project, and then archiving only the root level projects.

Even after you convert folders at root level to projects, the script logic would pretty much remain the same, except the loop - you'd need for item in folder do loop.

Re: Script to automate creation of DOORS Project Archive
llandale - Thu Apr 03 14:11:05 EDT 2014

SudarshanRao - Thu Apr 03 01:13:22 EDT 2014

It would be quite simple script, with a loop (for project in database do) and the archive function within it. But, since in DOORS you can have project within a project, simply archiving all projects may mean that you'd end up duplicating data.

So you may want to consider having all items at root level to be of type project, and then archiving only the root level projects.

Even after you convert folders at root level to projects, the script logic would pretty much remain the same, except the loop - you'd need for item in folder do loop.

Or bypass projects with parent projects:

  • if (!null getParentProject(item(fullName(p))) then continue

Re: Script to automate creation of DOORS Project Archive
Chris Annal - Fri Apr 04 12:45:40 EDT 2014

It's been a while since I posted a script to this forum - so I'm not sure if the formatting will hold, but below is a script that will archive all the projects in a DOORS database (except those that are currently locked because someone has a module open). It will email the results, listing all the projects that it archived and also list those that weren't archived because they were locked. It will give you the DOORS username of the culprit who was locking you out.

It's written to export the archived projects to a folder named "DOORS_Projects" on your C drive, so you'll have to create that folder if it doesn't exist. I would run this as a batch process, using a Windows scheduled task on the PC that runs it - so you can run it at night and get the results the next morning.

Good Luck!!

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//Archive Projects - CheckLocks
/*
Archive projects, after first checking to make sure they aren't locked - email results
*/

//Created 09/07/2011 - Saab Sensis Corp - C. Annal
/*******************************************************************************
 * Global constants
 */
// These must be changed to correspond to the user's email address, corporate email server and account
// that will send the email. The fromDescription and subject will appear as the "From" and
// "Subject" of the email.
const  string targetAddress = "<your email address>"
const  string  emailServer = "<corporate_email_server>"
const  string  emailAccount = "DOORS"
const string  fromDescription = "DOORS"
const string  subject = "Archive Results"

/*******************************************************************************
 * Global Variables
 */
Lock lockItem
LockList lcklist
string sProjectName
string message  = ""
Project pX
Buffer bx1=create, bx2=create

/*******************************************************************************
 * Function Declarations
 */
bool bLockedByAnyUser=true, bLocked

/*******************************************************************************
 * Script
 */

for pX in database do { 
sProjectName = name pX  
Project parent = getParentProject(pX)
if(null parent && !isDeleted pX){
   lcklist = getLocksInFolder(pX,true,bLockedByAnyUser)
   bLocked=false
for lockItem in lcklist do {
   bLocked=true;
   string lckuser = lockItem.user
   bx1+=sProjectName " locked by " lckuser "\n";
   break
}// End for lockItem in lcklist do
   if(bLocked)continue
   bx2+= sProjectName " was processed \n"
   string proj_archive = archive (sProjectName,"c:\\DOORS_Projects\\"(sProjectName)".dpa",false,true,allBaselines,false) 
if (!null proj_archive)
 {
  ack proj_archive
  halt
 }// End !null proj_archive
}// End if(null parent && !isDeleted pX)
}// End for pX in database do
message = bx1 "\n" bx2""
sendEMailNotification(
 fromDescription,
 targetAddress,
 subject,
 message)
//halt

Re: Script to automate creation of DOORS Project Archive
Chris Annal - Mon Apr 14 12:23:57 EDT 2014

Chris Annal - Fri Apr 04 12:45:40 EDT 2014

It's been a while since I posted a script to this forum - so I'm not sure if the formatting will hold, but below is a script that will archive all the projects in a DOORS database (except those that are currently locked because someone has a module open). It will email the results, listing all the projects that it archived and also list those that weren't archived because they were locked. It will give you the DOORS username of the culprit who was locking you out.

It's written to export the archived projects to a folder named "DOORS_Projects" on your C drive, so you'll have to create that folder if it doesn't exist. I would run this as a batch process, using a Windows scheduled task on the PC that runs it - so you can run it at night and get the results the next morning.

Good Luck!!

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

//Archive Projects - CheckLocks
/*
Archive projects, after first checking to make sure they aren't locked - email results
*/

//Created 09/07/2011 - Saab Sensis Corp - C. Annal
/*******************************************************************************
 * Global constants
 */
// These must be changed to correspond to the user's email address, corporate email server and account
// that will send the email. The fromDescription and subject will appear as the "From" and
// "Subject" of the email.
const  string targetAddress = "<your email address>"
const  string  emailServer = "<corporate_email_server>"
const  string  emailAccount = "DOORS"
const string  fromDescription = "DOORS"
const string  subject = "Archive Results"

/*******************************************************************************
 * Global Variables
 */
Lock lockItem
LockList lcklist
string sProjectName
string message  = ""
Project pX
Buffer bx1=create, bx2=create

/*******************************************************************************
 * Function Declarations
 */
bool bLockedByAnyUser=true, bLocked

/*******************************************************************************
 * Script
 */

for pX in database do { 
sProjectName = name pX  
Project parent = getParentProject(pX)
if(null parent && !isDeleted pX){
   lcklist = getLocksInFolder(pX,true,bLockedByAnyUser)
   bLocked=false
for lockItem in lcklist do {
   bLocked=true;
   string lckuser = lockItem.user
   bx1+=sProjectName " locked by " lckuser "\n";
   break
}// End for lockItem in lcklist do
   if(bLocked)continue
   bx2+= sProjectName " was processed \n"
   string proj_archive = archive (sProjectName,"c:\\DOORS_Projects\\"(sProjectName)".dpa",false,true,allBaselines,false) 
if (!null proj_archive)
 {
  ack proj_archive
  halt
 }// End !null proj_archive
}// End if(null parent && !isDeleted pX)
}// End for pX in database do
message = bx1 "\n" bx2""
sendEMailNotification(
 fromDescription,
 targetAddress,
 subject,
 message)
//halt

The only formatting issue with my code above (as far as I can tell) is that there is a single line of code that appears on two separate lines. This should all appear on the same line...

string proj_archive = archive (sProjectName,"c:\\DOORS_Projects\\"(sProjectName)".dpa",false,true,allBaselines,false)

...for that part of the code above, the "double slashes" appear as a comment line just before the "(sProjectName)".dpa

 

...sorry, the "new" format still confuses me.

Re: Script to automate creation of DOORS Project Archive
MikeMelon - Fri Nov 21 12:21:29 EST 2014

Hi Chris,

This is an excellent DXL script. It is working very well. I will be customizing the script slightly to meet my DOORS project needs.

Again thanks a bunch for this great DXL script to archive DOORS projects.

Best regards,

Mike